package com.my.thread.pool;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by ZhongGang
 * at 2018/7/13 11:26
 */
public class DefaultThreadFactory implements ThreadFactory {
    private AtomicInteger threadIndex = new AtomicInteger(0);

    @Override
    public Thread create(Runnable runnable) {
        String name = String.format("thread-%s", this.threadIndex.getAndIncrement());
        return new Thread(runnable, name);
    }
}
